package com.chs.recoginition.aip;

import com.alibaba.fastjson.JSONObject;
import com.chs.recoginition.core.config.FeignConfig;
import feign.Headers;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author CHS
 * @Date 2023/2/8 21:29
 * @Version 1.0
 **/
@FeignClient(name = "baiduBce", url = "${baidubce.address}", configuration = FeignConfig.class)
public interface ImageRecognitionClient {

    /**
     * 获取令牌
     *
     * @param grantType
     * @param clientId
     * @param clientSecret
     * @return
     */
    @RequestMapping(value = "/oauth/2.0/token", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getToken(@RequestParam("grant_type") String grantType, @RequestParam("client_id") String clientId,
                        @RequestParam("client_secret") String clientSecret);

    /**
     * 植物识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/plant", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getPlant(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 通用物品和场景识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v2/advanced_general", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getAdvancedGeneral(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 动物识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/animal", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getAnimal(@RequestBody MultiValueMap<String, Object> request);

    /**
     * logo识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v2/logo", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getLogo(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 果蔬识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/classify/ingredient", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getIngredient(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 菜品识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v2/dish", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getDish(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 红酒识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/redwine", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getRedWine(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 货币识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/currency", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getCurrency(@RequestBody MultiValueMap<String, Object> request);

    /**
     * 地标识别
     * @param request
     * @return
     */
    @RequestMapping(value = "/rest/2.0/image-classify/v1/landmark", method = RequestMethod.POST)
    @Headers(value = "Content-Type: application/x-www-form-urlencoded")
    JSONObject getLandmark(@RequestBody MultiValueMap<String, Object> request);


}
